package com.lsh.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lsh.common.util.PageSurport;
import com.lsh.dao.TbCategoryDao;
import com.lsh.model.TbCategory;

@Service("tbCategoryService")
public class TbCategoryService extends BasicService{

	@Autowired
	TbCategoryDao dao;
	
	@Transactional
	public void test() throws Exception {
//		TbCategory category =  dao.selectOne("TbCategory-getById", 9);
//		System.out.println(category.getName());
//		PageSurport page = new PageSurport();
//		page.setPageNo(2);
//		page.setPageSize(1);
//		Map map = new HashMap();
//		map.put("ename", "%%");
//		map.put("useable","1");
//		map.put("orderby","ID");
//		map.put("orderbyType","1");
//		page  = dao.selectPageByPage("TbCategory-getPage", "TbCategory-getPageCount", page, map);
//		List<TbCategory> categories = page.getItems();
//		for(TbCategory category : categories){
//			System.out.println(category.getName());
//		}
//		
//		System.out.println(page.toString());
		
		TbCategory category = new TbCategory();
		category.setName("name");
		category.setUseable(0);
		category.setParentid(1);
		dao.insert("TbCategory-insert", category);
		System.out.println(category.getId());
	}
}
